package net.datafans.exercise.redis;

import org.apache.log4j.xml.DOMConfigurator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class Test {
	String path = System.getProperty("user.dir");
	{
		DOMConfigurator.configure(path + "/conf/log4j.xml");
	}
	ApplicationContext ctx = new FileSystemXmlApplicationContext(path + "/conf/redis-Context.xml");

	void userTest() {
		UserDao userDao = (UserDao) ctx.getBean("userDao");
		String uid = "u123456";
		String address1 = "广州";
		User user = new User();
		user.setAddress(address1);
		user.setUid(uid);
		userDao.save(user);

		user = userDao.read(uid);
		System.out.println("address1=" + user.getAddress());
	}

	void simpleTest() {
		SimpleDaoImpl dao = (SimpleDaoImpl) ctx.getBean("simpleDao");
		dao.setString("name", "apache");
		System.out.println(dao.getString("name"));
		dao.setList("namelist", "java");
		System.out.println(dao.getList("namelist"));
		dao.setMap("namemap", "career", "computer");
		System.out.println(dao.getMap("namemap"));
	}
	public static void main(String[] args) {
		Test t = new Test();
		t.simpleTest();
		// t.userTest();
	}

}
